package edu.uj.petri.view;

import edu.uj.petri.commands.Restorable;
import edu.uj.petri.model.Node;
import java.awt.geom.Point2D;
import java.util.HashSet;
import java.util.Set;

/**
 * @author Piotrek
 */
public abstract class NodeView extends DiagramElement implements Restorable {
    
    protected Set<ArcView> arcs;
    protected Point2D position;
    
    public NodeView() {
        
        arcs = new HashSet<ArcView>();
    }
    
    public abstract Node getNode();

    public void addArc(ArcView arc) {
        
        arcs.add( arc );
    }

    public void removeArc(ArcView arc) {
        
        arcs.remove( arc );
    }

    /**
     * template method to re-count place of arcs
     */
    protected abstract void organiseArcs();

    /**
     * notifies NodeView that it arcs have been changed (added, deleted, moved)
     */
    public void arcsChanged() {
        organiseArcs();
    }
}
